<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">    
<form:form modelAttribute="searchForm" id="searchForm" method="post" class="form">   
	<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" > 
		<tr><td align="center" colspan="2"><h2>會期查詢</h2></td></tr>
		<tr>
			<td width="50%" align="right">會期編號：<form:input id="sessionNo1" path="sessionNo1" style="width:50px;"/>～</td><td><form:input id="sessionNo2" path="sessionNo2" style="width:50px;"/>(ex:900~1000)</td>
		</tr>
		<tr>
			<td align="right">臨時會期：<form:input id="xNo1" path="xNo1" style="width:50px;"/>～</td><td><form:input id="xNo2" path="xNo2" style="width:50px;"/>(ex:20~20)</td>
		</tr>
		<tr>
			<td align="right">會議日期：<form:input id="meetingDate1" path="meetingDate1" style="width:120px;" class="easyui-datebox"/>～</td>
			<td align="left"><form:input id="meetingDate2" path="meetingDate2" style="width:120px;" class="easyui-datebox"/>(yyyy/mm/dd)</td>
		</tr>
		<tr>
			<td align="center" colspan="2">
				<a href="#do" class="easyui-linkbutton" onclick="doSearch()">查詢</a> 
				<a href="#do" class="easyui-linkbutton" onclick="fmClean()">清空</a>
			</td>
		</tr>
	</table>	
</form:form>  
<br/> 
<table id="dg" class="easyui-datagrid" style="height:450px"  url="${appPath}/session/list.json" align="center" 
	singleSelect="true" striped="true" title="會期查詢" rownumbers="true" pagination="true"
	sortName="meetingDate" multiSort="true" sortable="true" sortOrder="desc">
	<thead>      
    	<tr>   
            <th field="sessionNo" width="150px" sortable="true" formatter="sessionFormat">會期</th>
            <th field="year" width="60px" sortable="true">年</th>  
            <th field="month" width="50px" sortable="true">月</th>  
            <th field="day" width="50px" sortable="true">日</th>
            <th field="action" width="180px" formatter="action">作業</th>  
		</tr>   
	</thead>   
</table> 
</div>
<script type="text/javascript">
$.ajaxSetup ({
    cache: false,
    async:false
});
$(function() {
    $( "#hid" ).hide();
    $( "#new" ).hide();
});
function sessionFormat(val,row,ix){ 
	return "第"+val+"期";
}
function action(val,row,ix){ var str = "";
	var o = $('#dg').datagrid('getData').rows[ix];
	<sec:authorize ifAnyGranted="imgUser">
	str = str.concat("[<a target='_p' href='${appPath}/motionView/"+o.sessionNo+".htm'>目次表</a>]");
	</sec:authorize>
	<sec:authorize ifAnyGranted="admin,subAdmin">
	$.ajax({url:"${appPath}/sessionView/isOpen/"+o.sessionNo+".json", 
		async:false ,cache:false, success:function(d){ 
			if(eval(d)){
				str = str.concat("[<a target='_p' href='${appPath}/motionView/"+o.sessionNo+".htm'>目次表</a>]");
				str = str.concat("[<a href='#' onclick=\"attr('"+o.sessionNo+"');\">檔案管理</a>]");  
			}else{
				str = str.concat("[尚未開放]");
			}
		}
	});			
	</sec:authorize>
	return str; 
} 
function doSearch(){ var object = {};
	$.each($('#searchForm').serializeArray(), function(i, v) { object[v.name] = v.value; });
	$('#dg').datagrid('load', object ); 
} 
function attr(id) {	window.open('${appPath}/files.htm?id='+id+"&m="+Math.random(),'attr','height=750,width=700,location=no,scrollbars=yes' );}
function fmClean(){$("#searchForm").form('reset');}

</script>